casual
Simple crate for parsing user input.
Getting started
Add the following dependency to your Cargo.toml
.
[]
= "0.1"
Usage
Rust type inference is used to know what to return.
let username: String = prompt.get;
FromStr
is used to parse the input, so you can read any type that implements
FromStr
.
let age: u32 = prompt.get;
.matches()
can be used to validate the input data.
let age: u32 = prompt.matches.get;
A convenience function confirm
is provided for getting a yes or no answer.
if confirm else
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.